<%@ Page Language="VB" AutoEventWireup="false" CodeFile="goto.aspx.vb" Inherits="goto_page"  aspcompat=true Debug="true" %>

<%
    Dim connstr, conn, pid, rs,Site_Url,TaokeUrl,shopid
    connstr = ConfigurationSettings.AppSettings("SQLConnString") & """" & Server.MapPath(".") & "\" & ConfigurationSettings.AppSettings("dbPath") & """"
    conn = Server.CreateObject("ADODB.Connection")
    conn.open(connstr)
    rs = Server.CreateObject("adodb.recordset")
    rs.open("select *  from Config", conn, 1, 3)
    pid = rs("Pid").value
    rs.close()
	Site_Url = "http://" & Request.ServerVariables("server_name") & Request.ServerVariables("script_name")
	Site_Url=left(Site_Url,instrrev(Site_Url,"/"))
	shopid=request.QueryString("Shopid")
	if shopid<>"" then
		if left(shopid,2)="88" and right(shopid,2)="88" then
			TaokeUrl = GetShopTaoKeUrl
			TaokeUrl = Replace(TaokeUrl, "Pid", pid)
			response.Write("<meta HTTP-EQUIV=""REFRESH"" CONTENT=""0;URL=" & TaokeUrl & """>")
			response.End()
		end if
	  	rs.open("select  *  from Goods_Saller_Temp where id=" & int(shopid), conn, 1, 3)
		if not rs.eof then
			TaokeUrl = rs("TaokeUrl").value & pid
			response.Write("<meta HTTP-EQUIV=""REFRESH"" CONTENT=""0;URL=" & TaokeUrl & """>")
			response.End()
		end if
	end if
 %>
<%
    Dim cid
    If request("cid") <> "" Then
        cid = request("cid")
		If Left(cid, 6) = "168861" Then
			TaokeUrl=GetTaokeUrl
			
		else
			cid = Replace(cid, "'", "''")
			rs = server.createobject("adodb.recordset")
			rs.open("select  *  from commodity where CID='" & cid & "'", conn, 1, 3)
			If Not rs.eof Then
				TaokeUrl = rs("TaokeUrl").value
				TaokeUrl = Replace(TaokeUrl, "_Pid_", "_" & pid & "_")
			else
				TaokeUrl=Site_Url
			end if
		end if

%>
<meta HTTP-EQUIV="REFRESH" CONTENT="0;URL=<%=TaokeUrl%>">
<%
response.End()
end if
%>
<%
    shopid = Replace(request("sid"), "'", "''")
    rs = server.createobject("adodb.recordset")
    rs.open("select  *  from url where Url_Id=" & shopid, conn, 1, 3)
    If Not rs.eof Then
		TaokeUrl=rs("SHOPURL").value
		if instr(TaokeUrl,"Pid") then
			TaokeUrl=replace(TaokeUrl,"Pid",pid)
		else
			TaokeUrl=TaokeUrl & pid
		end if
		
%>
<meta HTTP-EQUIV="REFRESH" CONTENT="1;URL=<%=TaokeUrl%>">


<%
else
%>
<script type="text/javascript">
location.href='<%=Site_Url%>';
</script>
<%
end if
%>
<%
GC.Collect()
%>